
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>用户修改</title>
		<%@ include file="/commons/css_js_head.jsp"%>
<script type="text/javascript">
//复写Url
doUpdateUrl = "${ctx }/permission/efUserAction!doUpdate.ts";
doReturnUrl = "${ctx }/permission/efUserAction!doList.ts";

//校验用户账号是否存在
function checkUserAccountIsExist() {
	var txtObj = document.getElementById("efUser.userAccount");
	var userAccountInfo = document.getElementById("userAccountInfo");
	var tUserAccount = txtObj.value;
	if(tUserAccount == ""){
		var innerHtml = "<span class='ts_red'>请输入用户账号！<\/span>";
		getFocus(txtObj,userAccountInfo,innerHtml);
		return false;
	}else if(tUserAccount.length < 5 || tUserAccount.length > 32){
		var innerHtml = "<span class='ts_red'>用户帐号只能在5-32个字符之间！<\/span>";
		cleanDataAndGetFocus(txtObj,userAccountInfo,innerHtml);
		return false;
	}
	
    $.ajax({
      type : "post",
      url : "${ctx }/permission/efUserAction!doCheckUserAccountIsExist.ts",
      cache: false,
      data : "&userAccount="+tUserAccount,
      success : function(data){
      
      if( data == "true" )
       {
           var innerHtml = "<span class='ts_red'>该用户账号已经存在，请重新输入！<\/span>";
           userAccountInfo.innerHTML=innerHtml;
           txtObj.value = "";
           txtObj.focus();
           return false;
        }
       else
       {
           var innerHtml = "<span class='ts_green'>验证通过，该用户账号可以使用！<\/span>";
           userAccountInfo.innerHTML=innerHtml;
           return true;
       }
      },
     error: function(){
     	   var innerHtml = "<span class='ts_red'>服务繁忙，请稍后再试！<\/span>";
           userAccountInfo.innerHTML=innerHtml;
           txtObj.value = "";
           return false;
     	}
   });
  	return true;
}

//验证密码
function checkUsesPassword() {
	var userPassword = document.getElementById("efUser.userPassword");
	var userPasswordInfo = document.getElementById("userPasswordInfo");
	
	if(userPassword.value == ""){
		var innerHtml = "<span class='ts_red'>请输入用户密码！<\/span>";
		cleanData(userPassword,userPasswordInfo,innerHtml);
		return false;
	}else if(userPassword.value.length < 6 || userPassword.value.length > 12){
		var innerHtml = "<span class='ts_red'>用户密码只能在6-12个字符之间！<\/span>";
		cleanData(userPassword,userPasswordInfo,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过，该密码可以使用！<\/span>";
		disInfo(userPasswordInfo,innerHtml);
		return true;
	}
}

//验证重复密码
function checkReUsesPassword() {
	var userPassword = document.getElementById("efUser.userPassword");

	var reUserPassword = document.getElementById("efUser.reUserPassword");
	var reUserPasswordInfo = document.getElementById("reUserPasswordInfo");
	
	if(reUserPassword.value == ""){
		var innerHtml = "<span class='ts_red'>请输入重复密码！<\/span>";
		cleanData(reUserPassword,reUserPasswordInfo,innerHtml);
		return false;
	}else if(reUserPassword.value.length < 6 || reUserPassword.value.length > 12){
		var innerHtml = "<span class='ts_red'>重复密码只能在6-12个字符之间！<\/span>";
		cleanData(reUserPassword,reUserPasswordInfo,innerHtml);
		return false;
	}else if(userPassword.value != reUserPassword.value){
		var innerHtml = "<span class='ts_red'>重复密码与用户密码不相同，请重新输入！<\/span>";
		cleanData(reUserPassword,reUserPasswordInfo,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过，两次输入密码一致！<\/span>";
		disInfo(reUserPasswordInfo,innerHtml);
		return true;
	}
}

//验证用户名称
function checkUserName() {

	var userName = document.getElementById("efUser.userName");
	var userNameInfo = document.getElementById("userNameInfo");
	
	if(userName.value == ""){
		var innerHtml = "<span class='ts_red'>请输入用户名称！<\/span>";
		cleanData(userName,userNameInfo,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(userNameInfo,innerHtml);
		return true;
	}
}

//验证所属机构
function checkOrgId() {

	var orgId = document.getElementById("efUser.efOrg.orgId");
	var orgIdInfo = document.getElementById("orgIdInfo");
	
	if(orgId.value == ""){
		var innerHtml = "<span class='ts_red'>请选择所属机构！<\/span>";
		cleanData(orgId,orgIdInfo,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(orgIdInfo,innerHtml);
		return true;
	}
}

//验证手机号
function checkUserMobile() {

	var userMobile = document.getElementById("efUser.userMobile");
	var userMobileInfo = document.getElementById("userMobileInfo");
	
	if(userMobile.value == ""){
		var innerHtml = "<span class='ts_red'>请输入手机号！<\/span>";
		cleanData(userMobile,userMobileInfo,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(userMobileInfo,innerHtml);
		return true;
	}
}

//验证职位
function checkUserPosition() {

	var dicUserPosition = document.getElementById("efUser.dicUserPosition");
	var dicUserPositionInfo = document.getElementById("dicUserPositionInfo");
	
	if(dicUserPosition.value == ""){
		var innerHtml = "<span class='ts_red'>请选择职位！<\/span>";
		cleanData(dicUserPosition,dicUserPositionInfo,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(dicUserPositionInfo,innerHtml);
		return true;
	}
}

//验证类别 
function checkUserType() {

	var dicUserType = document.getElementById("efUser.dicUserType");
	var dicUserTypeInfo = document.getElementById("dicUserTypeInfo");
	
	if(dicUserType.value == ""){
		var innerHtml = "<span class='ts_red'>请选择类别！<\/span>";
		cleanData(dicUserType,dicUserTypeInfo,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(dicUserTypeInfo,innerHtml);
		return true;
	}
}

function checkForm(){
	
	if(
		
		checkUserMobile()){
		return true;
	}else{
		return false;
	}
}

//更新
function doUpdate(){
   var _form = document.forms[0];
   if(doUpdateUrl == ''){
   	alert('请设置正确的URL!');
   	return false; 
   }
	
	if(checkForm()){
	   _form.action = doUpdateUrl;
	   _form.submit();
   }
}
</script>
	</head>

	<body style="overflow-x: hidden">
		<div class="mTitle">
			<span class="hidsearch"></span>
			<b class="bbig">用户修改</b> 带
			<b class="fred"> * </b>号为必填项
		</div>

		<form action="/permission/efUserAction" method="post">
			<s:hidden name="efUser.userId"></s:hidden>
			<s:hidden name="efUser.userPassword"></s:hidden>
			<!--list -->
			<div class="mainAdd">
				<table class="addTable">

					<tr>
						<td colspan="4">
							<b class="fblue">1、账号信息</b>
						</td>
					</tr>

					<tr>
						<th>
							<b class="fred"> * </b> 用户账号：
							
						</th>
						<td colspan="3">
							<s:textfield name="efUser.userAccount" maxlength="32" theme="simple" cssStyle="background:#ECEEEC" readonly="true" />
							<span id="userAccountInfo"></span>
						</td>
						
					</tr>

					<tr>
						<td colspan="4">
							<b class="fblue">2、用户公司信息</b>
						</td>
					</tr>
					
					<tr>
					    <th>
							<b class="fred"> * </b> 厂家编码：
						</th>
						<td colspan="3">
							<s:textfield name="efUser.compCode"  maxlength="6" theme="simple"/>
							<span id="usercode111"></span>
						</td>
						</tr>
						<tr>
						<th>
							<b class="fred"> * </b> 公司名称：
						</th>
						<td colspan="3">
							<s:textfield name="efUser.compName" maxlength="16" theme="simple" ></s:textfield>
							<span id="userNameInfo"></span>
						</td>
						
					</tr>
					<tr>
					    <th>
							<b class="fred"> * </b> 负责人：
						</th>
						<td colspan="3">
							<s:textfield name="efUser.userName"  maxlength="6" theme="simple"/>
						</td>
						</tr>
					<tr>
					<tr>
						<th>
							<b class="fred"> * </b> 性别：
						</th>
						<td>
							<select name="efUser.dicUserSex">
								<ef:option groupname="DicSex" selectedValue="${efUser.dicUserSex}" ></ef:option>
							</select>
						</td>
				  </tr>
						
						
						<th>
							<b class="fred"> * </b> 联系号码：
						</th>
						<td colspan="3">
							<s:textfield name="efUser.userMobile" maxlength="64" theme="simple" onblur="checkUserMobile()"></s:textfield>
							<span id="userMobileInfo"></span>
						</td>
						</tr>
						<tr>
						<th>
							<b class="fred"> * </b> 营业执照：
						</th>
						<td colspan="3">
							<s:textfield name="efUser.businessLicense" maxlength="64" theme="simple" ></s:textfield>
							<span id="userMobileInfo"></span>
						</td>
					</tr>
					
					<tr>
						<th>
							<b class="fred"> * </b> 用户状态：
						</th>
						<td colspan="3">
							<select name="efUser.dicUserIsValid">
								<ef:option groupname="DicUserIsValid" selectedValue="${efUser.dicUserIsValid}" link="true"></ef:option>
							</select>
							<span id="dicUserIsValidInfo"></span>
						</td>
						</tr>
					<tr>
						<th>
							无效原因：
						</th>
						<td colspan="3">
							<s:textfield name="efUser.validReason" maxlength="128" theme="simple"></s:textfield>
						</td>
					</tr>
					
				</table>
			</div>
			<!--end list -->
			<div class="addToolbar">
				<p>
					<input class="btn" name="btn_confirm" value="确定" type="button"
						onclick="doUpdate();" />
					<input class="btn" name="btn_return" value="返回" type="button"
						onclick="doReturn();" ; />
				</p>
			</div>

		</form>

	</body>

<script type="text/javascript">
document.onkeydown = function(e) {
	if (!e)
		e = window.event;//火狐中是 window.event
	if ((e.keyCode || e.which) == 13) {
		doUpdate();
	}
}
</script>
</html>
